package com.yifan.diyFuncion.case1;

import org.springframework.util.StringUtils;

/**
 * @Author YIFan
 * @Date 2023-5-13 14:41
 * @Version 1.0
 */
public class FuncIfUtil {

    public static ThrowExceptionFunction isTrue(Boolean bool) {
        return message -> {
            if (!bool) throw new RuntimeException(message);
        };
    }

    public static NullBranchHandlerFunction<Object> isNull(Object obj) {
        return (trueHandler, falseHandle) -> {
            if (StringUtils.isEmpty(obj)) {
                System.err.println("为空");
                trueHandler.run();
            } else {
                System.out.println("不为空");
                falseHandle.accept(obj);
            }
        };
    }
}
